<?php
	if(isset($_POST['card_num']))
	{
	require_once '../inc/anet_php_sdk/AuthorizeNet.php'; // Make sure this path is correct.
	$transaction = new AuthorizeNetAIM('4tD26vR7', '4U68C3vrr6DxH47Z');
	
	$transaction->amount = $_POST['price'];
	$transaction->card_num = $_POST['card_num'];
	$transaction->exp_date = $_POST['exp_date'];
	
	$response = $transaction->authorizeAndCapture();
	}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Home Page</title>
    <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css">
    <link rel="stylesheet" type="text/css" href="../inc/bootstrap.css">
</head>

<body>
        <? include('../inc/header.php'); ?>
        <div class="container">
			<? include('../inc/nav.php'); ?>
            <pre>
			<?
				if (isset($response)) {
					print_r($response);
				}
			?>
            </pre>
            
            <form action="?" method="post">
            	Price: <input type="number" name="price" /> <br />
                Credit Card Number: <input type="text" name="card_num" /> <br />
                Experation Date: <input type="text" name="exp_date" />
                <input type="submit" value="Buy Now" />
            </form>
		</div>
        <div id="fb-root"></div>
		<script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) return;
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));</script>
</body>
</html>


